<template>
  <svg
    :class="svgClass"
    aria-hidden="true"
    :style="{ color: color, fontSize: size }"
  >
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts">
import { computed } from "vue";
const props = defineProps({
  name: {
    type: String,
    required: true,
  },
  color: {
    type: String,
    default: "",
  },
  size: {
    type: Number,
  },
});
const iconName = computed(() => `#${props.name}`);
const svgClass = computed(() => {
  if (props.name) return `svg-icon icon-${props.name}`;
  return "svg-icon";
});
</script>

<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  stroke: currentColor;
  vertical-align: middle;
  overflow: hidden;
}
</style>
